/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.lidovky.articles.domain;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Martin Řehánek (rehan@mzk.cz)
 */
public class NumberInterval {

    private int start;
    private int end;

    private NumberInterval() {
    }

    ;

    public NumberInterval(int start, int end) {
        this.start = start;
        this.end = end;
    }

    /**
     * @return the start
     */
    public int getStart() {
        return start;
    }

    /**
     * @return the end
     */
    public int getEnd() {
        return end;
    }

    public int size() {
        return end - start + 1;
    }

    /**
     *
     * @return List of numbers from interval in ascending order
     */
    public List<Integer> toNumberList() {
        List<Integer> result = new ArrayList<Integer>(end - start + 1);
        for (int i = start; i <= end; i++) {
            result.add(Integer.valueOf(i));
        }
        return result;
    }
}
